#include <iostream>
#include <string>
using namespace std;

bool cmp(string a,string b){
	if(a.length() > b.length())
		return true;
	else if(b.length() > a.length())
		return false;
	else{
		for(int i=0;i<a.length();i++){
			if(a[i] > b[i])
				return true;
			else if(b[i] > a[i])
				return false;
		}
	}
	return false;
}

int main(){
	string ans="1";
	string s;
	cin>>s;
	string now="";
	bool pass=false,have_n=false;
	for(int i=0;i<s.length();i++){
		if(s[i] == '*'){
			if(now == "0")
				pass = true;
			now = "";
			i += 2;
		}
		else if(s[i] == '+'){
			if(!pass){
				if(have_n){
					if(cmp(now,ans))
						ans = now;
				}
				else{
					if(now != "0"){
						have_n = true;
						ans = now;
					}
				}
			}
			else{
				pass = false;
			}
			now = "";
		}
		else if(!pass){
			now += s[i];
		}
	}
	if(have_n)
		cout<<"O(n^"<<ans<<")";
	else
		cout<<"O(1)";
	return 0;
}
